
/********

Project - College affirmative action bans and health risk behaviors

Dataset - Annual Social and Economic Supplement (ASEC) of the CPS

Version - May 29, 2019 (for replication archive)

Description - This file contains the code used to generate S7 Table. The datafile "ASEC_datafile.dta" was created
by "datasetup_ASEC.do"

To run this analysis, the user will need to install the following stata routines:
-outreg2-
-reghdfe-

********/

***SET FILE PATHS AND CALL DATASET

global data "[YOUR FILEPATH]"  /*calls in all data used for the project */
global outreg "[YOUR FILEPATH]"  /*file to house data output*/

use "$data/ASEC_analysis_datafile.dta", clear

****USE ANALYSIS DATASET

****CREATE AA BAN EXPOSURE

**Main binary variable

gen aa_jel2016=.
replace aa_jel2016=0
replace aa_jel2016=1 if stfips==48 & year>=1997
replace aa_jel2016=0 if stfips==12 & year<2001
replace aa_jel2016=1 if stfips==12 & year>=2001
replace aa_jel2016=0 if stfips==06 & year<1998
replace aa_jel2016=1 if stfips==06 & year>=1998
replace aa_jel2016=0 if stfips==53 & year<1999
replace aa_jel2016=1 if stfips==53 & year>=1999
replace aa_jel2016=0 if stfips==26 & year<2006
replace aa_jel2016=1 if stfips==26 & year>=2006
replace aa_jel2016=0 if stfips==04 & year<2010
replace aa_jel2016=1 if stfips==04 & year>=2010
replace aa_jel2016=0 if stfips==33 & year<2012
replace aa_jel2016=1 if stfips==33 & year>=2012
replace aa_jel2016=0 if stfips==40 & year<2013
replace aa_jel2016=1 if stfips==40 & year>=2013
replace aa_jel2016=0 if stfips==31 & year<2008
replace aa_jel2016=1 if stfips==31 & year>=2008
sort year


*Exclude from estimation sample states that considered, but did not pass, affirmative action bans over a long period of time.
*Specifically, these are states that had multi-year litigation around affirmative action. 
*We note that Colorado considered an affirmative action ban as part of a voter initiative in 2008 that was narrowly defeated. We
*do not exclude Colorado though given that the ban was only considered over a short time frame (<1 year). (The reader can verify that
*excluding Colorado does not change the results at all)
 
gen est_sample = 1
recode est_sample (1=.) if stfip==1|stfip==13|stfip==22|stfip==28

***RUN REGRESSIONS

*SCHOOL ATTENDANCE

*Full and restricted samples, respectively

	xi: reghdfe school_attn aa_jel if race_min==2, abs(statefip year statefip#c.year age sex race)  cluster(statefip)
		outreg2 using "$outreg/S7_table_schoolfull", excel stats(coef ci pval se) 

	xi: reghdfe school_attn aa_jel if race_min==2&est_samp==1, abs(statefip year statefip#c.year age sex race)  cluster(statefip)
		outreg2 using "$outreg/S7_table_schoolrestricted", excel stats(coef ci pval se) 


*1 YEAR MIGRATION

*Full and restricted samples, respectively

	xi: reghdfe xstate_migr1 aa_jel if race_min==2, abs(statefip year statefip#c.year age sex race)  cluster(statefip)
			outreg2 using "$outreg/S7_table_migrfull", excel stats(coef ci pval se) 

	xi: reghdfe xstate_migr1 aa_jel if race_min==2&est_samp==1, abs(statefip year statefip#c.year age sex race)  cluster(statefip)
		outreg2 using "$outreg/S7_table_migrrestricted", excel stats(coef ci pval se) 

